package com.huawei.M01.iterator.May05;

import java.util.Arrays;

/**
 * 工作时间最长的员工
 *
 * @author 111
 */
public class LongestWorker {
    public int hardestWorker(int n, int[][] logs) {
        int len = logs.length;
        int[][] workers = new int[len][len];
        for (int i = 0; i < len; i++) {
            if (i == 0) {
                workers[i][0] = logs[i][1];
            } else {
                workers[i][0] = logs[i][1] - logs[i - 1][1];
            }
            workers[i][1] = logs[i][0];
        }
        Arrays.sort(workers, (a, b) -> a[0] == b[0] ? b[1] - a[1] : a[0] - b[0]);
        return workers[len - 1][1];
    }

    public static void main(String[] args) {

    }
}
